package org.evan.spring.validator.two;

import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindException;
import org.springframework.validation.Validator;

@Component
public class MyValidation2 {

    @Resource
    private Validator validator;

    public boolean validate(User user) {
        BindException bindException = new BindException(user,user.getName());
        validator.validate(user,bindException);
        return bindException.hasErrors();
    }
}
